
using Mengsk.ProxyDelivery.Domain;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Mengsk.ProxyDelivery.Service
{
    public class WarehouseService : ServiceBase<Warehouse>
    {
        const string APIURL_INSERT = "/webservice/warehouse/insert.html";
        const string APIURL_UPDATE = "/webservice/warehouse/update.html";

        //public Warehouse[] GetAll()
        //{
        //    Request req = new Request { Api = "getPageByMap" };
        //    req.Parameters.Add(new Parameter("para", new Dictionary<string, string>()));
        //    req.Parameters.Add(new Parameter("pageIndex", 0));
        //    req.Parameters.Add(new Parameter("pageSize", 0));

        //    return this.DoRemoteCall<Warehouse>(req).Datas.ToArray();
        //}

        public int Insert(Warehouse warehouse)
        {
            IDictionary<string, string> para = new Dictionary<string, string>();
            para["name"] = warehouse.Name;
            para["phone"] = warehouse.Phone;
            para["address"] = warehouse.Address;
            para["enabled"] = warehouse.Enabled.ToString();
            return this.DoPost<int>(APIURL_INSERT, para).Datas[0];
        }

        public void Update(Warehouse warehouse)
        {
            IDictionary<string, string> para = new Dictionary<string, string>();
            para["id"] = warehouse.Id.ToString();
            para["phone"] = warehouse.Phone;
            para["address"] = warehouse.Address;
            para["enabled"] = warehouse.Enabled.ToString();
            this.DoPost<int>(APIURL_UPDATE, para);
        }
    }
}
